import { BasicFetchResult } from '../model/baseModel';
import { defHttp } from '@/utils/http/axios';
import { downloadBlob } from '@/utils/file/download';
enum Api {
  SysPosApi = '/sysPos',
}
/**
 * 查询系统职位表不分页
 * @author frank
 * @date 2022-09-14 16:20:59
 */
export const getSysPosList = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: Api.SysPosApi + '/list', params });
/**
 * 添加系统职位表
 * @author frank
 * @date 2022-09-14 16:20:59
 */
export const addSysPos = (params?: any) => defHttp.post({ url: Api.SysPosApi + '/add', params });
/**
 * 修改系统职位表
 * @author frank
 * @date 2022-09-14 16:20:59
 */
export const editSysPos = (params?: any) => defHttp.post({ url: Api.SysPosApi + '/edit', params });

/**
 * 删除系统职位表
 * @author frank
 * @date 2022-09-14 16:20:59
 */
export const deleteSysPos = (ids: string[]) =>
  defHttp.post({ url: Api.SysPosApi + '/delete', params: ids });
/**
 * 导出系统职位表
 * @author frank
 * @date 2022-09-14 16:20:59
 */
export const exportSysPos = (params?: any) => {
  return new Promise<void>((resolve, reject) => {
    defHttp
      .get(
        { responseType: 'blob', url: Api.SysPosApi + '/export', params },
        { isReturnNativeResponse: true },
      )
      .then((res) => {
        downloadBlob(res);
        resolve();
      })
      .catch(() => {
        reject();
      });
  });
};
